package cc.cocosky.imclient;

import java.io.IOException;
import java.net.InetSocketAddress;

public class StressTest implements OnReceiveHandler {
	
	private static final String host = "127.0.0.1";
	private static final int port = 8899;
	
	public void test() {
		InetSocketAddress address = new InetSocketAddress(host, port);
		for(int i = 0; i < 10000; i ++) {
			SocketInvoker socketInvoker = new SocketInvoker();
			try {
				socketInvoker.setOnReceiveHandler(this);
				socketInvoker.connect(address);
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
	
	@Override
	public void onReceive(byte[] data) {
		System.out.println(new String(data));
	}

	public static void main(String[] args) {
		
		StressTest tester = new StressTest();
		tester.test();

	}

}
